package cn.legend.travel.admin.user.pojo.entity;

import cn.legend.travel.admin.user.pojo.param.UserUpdateParam;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

@Data
@TableName("normal_user_table")
public class User implements Serializable {
    @TableId(type = IdType.AUTO)
    Long id;
    String username;
    String password;
    String nickname;
    Integer state;
    String phone;
    String wechat;
    String weibo;
    String qq;
    String email;
    String avatar;
    String lastLoginIp;
    Date gmtLastLogin;
    Integer messageEnable;
    Integer level;
    Integer sex;
    String city;
    Date birthday;
    String brief;
    Integer shouldCheck;
    /**
     * 数据创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    LocalDateTime gmtCreate;
    /**
     * 数据最后修改时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    LocalDateTime gmtModified;

    public User() {
    }

    public User(UserUpdateParam param) {
        id = param.getId();
        nickname = param.getDeleteNickname() == 0 ? null : "用户:" + param.getUsername();
        avatar = param.getDeleteAvatar() == 0 ? null : "http://176.223.7.20:50200/image.jpg";
        brief = param.getDeleteBrief() == 0 ? null : "";
        state = param.getState();
    }
}
